package com.gqr.uncaughtException;

/**
 * Copyright (C), 2020-2024,gqr
 * FileName:UseOwnUncaughtExceptionHandler
 * author:guqingrong
 * Date:2024-04-25 22:19
 * Description:使用MyUncaughtExceptionHandler
 * History:
 * <author>    <time>    <version>    <desc>
 * 作者姓名     修改时间     版本号        描述
 */
public class UseOwnUncaughtExceptionHandler implements Runnable {
    public static void main(String[] args) throws InterruptedException {
        Thread.setDefaultUncaughtExceptionHandler(new MyUncaughtExceptionHandler("捕获器1"));
        new Thread(new UseOwnUncaughtExceptionHandler(), "线程1").start();
        Thread.sleep(300);

        new Thread(new UseOwnUncaughtExceptionHandler(), "线程2").start();
        Thread.sleep(300);

        new Thread(new UseOwnUncaughtExceptionHandler(), "线程3").start();
        Thread.sleep(300);

        new Thread(new UseOwnUncaughtExceptionHandler(), "线程4").start();

        System.out.println("主线程执行完成");
    }

    @Override
    public void run() {
        throw new RuntimeException();
    }
}
